<html>
<head><meta charset="utf-8"><title>Variance &amp; GAT? · wg-traits · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/index.html">wg-traits</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20GAT.3F.html">Variance &amp; GAT?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="216596600"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20GAT%3F/near/216596600" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Avi Dessauer <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20GAT.3F.html#216596600">(Nov 13 2020 at 11:10)</a>:</h4>
<p>Does <code>&lt;T as Life&gt;::L&lt;'a&gt;</code> have to be invariant?<br>
If so why? I have tried looking into this, but only found <a href="https://github.com/rust-lang/rust/issues/57440">tangentially related issues</a>.</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">trait</span><span class="w"> </span><span class="n">Life</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">type</span> <span class="nc">L</span><span class="o">&lt;'</span><span class="na">l</span><span class="o">&gt;</span>: <span class="o">'</span><span class="na">l</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="216596907"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20GAT%3F/near/216596907" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20GAT.3F.html#216596907">(Nov 13 2020 at 11:13)</a>:</h4>
<p>how can it not be <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span> </p>
<p>Would you restrict <code>L&lt;'l&gt;</code> to only allow types which use <code>'l</code> in co/contravariant positions?</p>



<a name="216597040"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20GAT%3F/near/216597040" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20GAT.3F.html#216597040">(Nov 13 2020 at 11:15)</a>:</h4>
<p>let's say you have</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">impl</span><span class="w"> </span><span class="n">Life</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="nb">String</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">type</span> <span class="nc">L</span><span class="o">&lt;'</span><span class="na">l</span><span class="o">&gt;</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">&amp;'</span><span class="na">l</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="o">&amp;'</span><span class="na">l</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="nb">String</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="216597210"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20GAT%3F/near/216597210" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20GAT.3F.html#216597210">(Nov 13 2020 at 11:17)</a>:</h4>
<p>if <code>L&lt;'l&gt;</code> was covariant, you could shrink the lifetime <code>'l</code> and overwrite the inner reference with a reference of the shorter lifetime, which can now be accessed using original lt.</p>



<a name="216597789"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20GAT%3F/near/216597789" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Avi Dessauer <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20GAT.3F.html#216597789">(Nov 13 2020 at 11:25)</a>:</h4>
<p>Could you give an example? I'm still not seeing it.</p>
<p>How can <code>'l</code> be used in a invariant position?<br>
<code>&amp;'l mut &amp;'invariant_position mut String</code>?</p>



<a name="216598401"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20GAT%3F/near/216598401" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Avi Dessauer <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20GAT.3F.html#216598401">(Nov 13 2020 at 11:33)</a>:</h4>
<p>Are you referring to the example in the nomicon?</p>



<a name="216599133"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20GAT%3F/near/216599133" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20GAT.3F.html#216599133">(Nov 13 2020 at 11:40)</a>:</h4>
<p>i am currently trying to write an example of what I have in mind</p>



<a name="216600360"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20GAT%3F/near/216600360" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Avi Dessauer <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20GAT.3F.html#216600360">(Nov 13 2020 at 11:52)</a>:</h4>
<p>I am starting to see the issue, or at least a issue.</p>
<p>However, if we must always assume GATs to be invariant how can they be used to model HKT?<br>
In a hypothetical world with HKT <code>T&lt;'_&gt;</code> would be covariant?</p>



<a name="216600606"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20GAT%3F/near/216600606" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Avi Dessauer <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20GAT.3F.html#216600606">(Nov 13 2020 at 11:55)</a>:</h4>
<p>Or would it also have to be invariant, since <code>'_</code> could be used inside a struct in a invariant position?</p>



<a name="216600806"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20GAT%3F/near/216600806" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20GAT.3F.html#216600806">(Nov 13 2020 at 11:57)</a>:</h4>
<p>that's what I am talking about think about <code>Foo</code> as <code>&lt;T as Life&gt;::L&lt;'a&gt;</code></p>



<a name="216600813"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20GAT%3F/near/216600813" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20GAT.3F.html#216600813">(Nov 13 2020 at 11:57)</a>:</h4>
<p><a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=de3c32c7990f001562d2d83e5ab5cffe">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=de3c32c7990f001562d2d83e5ab5cffe</a></p>



<a name="216600921"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20GAT%3F/near/216600921" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20GAT.3F.html#216600921">(Nov 13 2020 at 11:58)</a>:</h4>
<p><span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span>  it might make sense to add a way for associated types to be covariant, but that seems like a really complex addition for such a niche feature</p>



<a name="216601086"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20GAT%3F/near/216601086" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Avi Dessauer <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20GAT.3F.html#216601086">(Nov 13 2020 at 12:00)</a>:</h4>
<p>I'm not clear how any of the HKT modeling patterns could work without it.</p>



<a name="216602010"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20GAT%3F/near/216602010" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Avi Dessauer <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20GAT.3F.html#216602010">(Nov 13 2020 at 12:13)</a>:</h4>
<p>Forget HKT basic core GAT goals don't work.</p>
<p><a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=62e774a187e40ed7f7c5e28912090f3f">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=62e774a187e40ed7f7c5e28912090f3f</a></p>



<a name="216602402"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20GAT%3F/near/216602402" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20GAT.3F.html#216602402">(Nov 13 2020 at 12:16)</a>:</h4>
<p>why is that a basic core GAT goal?</p>



<a name="216602438"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20GAT%3F/near/216602438" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20GAT.3F.html#216602438">(Nov 13 2020 at 12:16)</a>:</h4>
<p>considering that it would be unsound</p>



<a name="216602465"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20GAT%3F/near/216602465" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Avi Dessauer <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20GAT.3F.html#216602465">(Nov 13 2020 at 12:16)</a>:</h4>
<p>How would it be unsound?</p>



<a name="216602492"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20GAT%3F/near/216602492" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20GAT.3F.html#216602492">(Nov 13 2020 at 12:17)</a>:</h4>
<p>you can freely overwrite <code>PartialEq</code> for <code>T::Item</code> and if <code>T::Item</code> is invariant you once again have the above issue</p>



<a name="216602728"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20GAT%3F/near/216602728" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Avi Dessauer <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20GAT.3F.html#216602728">(Nov 13 2020 at 12:20)</a>:</h4>
<p>I would consider comparing two items from different streaming iterators of the same type to be a requirement.<br>
I can certently do that with other language's streams.</p>



<a name="216603055"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20GAT%3F/near/216603055" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20GAT.3F.html#216603055">(Nov 13 2020 at 12:24)</a>:</h4>
<p>you can do that <a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=638fd83db23d2c652386ec5dfb7320bb">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=638fd83db23d2c652386ec5dfb7320bb</a></p>



<a name="216603088"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20GAT%3F/near/216603088" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20GAT.3F.html#216603088">(Nov 13 2020 at 12:25)</a>:</h4>
<p>you either have to call <code>next</code> in the same scope or have a concrete type for <code>Item</code></p>



<a name="216603096"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20GAT%3F/near/216603096" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20GAT.3F.html#216603096">(Nov 13 2020 at 12:25)</a>:</h4>
<p>at which point variance should work as expected</p>



<a name="216603148"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20GAT%3F/near/216603148" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20GAT.3F.html#216603148">(Nov 13 2020 at 12:26)</a>:</h4>
<p>fixed the implementation <a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=ea7bc62ad49482f40bbd5da5d97d9728">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=ea7bc62ad49482f40bbd5da5d97d9728</a></p>



<a name="216603483"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20GAT%3F/near/216603483" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Avi Dessauer <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20GAT.3F.html#216603483">(Nov 13 2020 at 12:30)</a>:</h4>
<p>But that's exactly the issue.<br>
How is a streaming iterator useful if the GATs can't be passed into functions?</p>



<a name="216603535"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20GAT%3F/near/216603535" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20GAT.3F.html#216603535">(Nov 13 2020 at 12:31)</a>:</h4>
<p>well they can</p>



<a name="216603635"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20GAT%3F/near/216603635" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Avi Dessauer <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20GAT.3F.html#216603635">(Nov 13 2020 at 12:32)</a>:</h4>
<p>They become invariant upon passing, no?</p>
<p>Was this limitation ever discussed in the RFC or internals?</p>



<a name="216604215"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20GAT%3F/near/216604215" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Avi Dessauer <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20GAT.3F.html#216604215">(Nov 13 2020 at 12:38)</a>:</h4>
<p>In the context of this discussion what would the proposed type equality constraint denote.</p>
<p>Could <code>where T::Item&lt;'a&gt; == T::Item&lt;'b&gt;</code> ever be satisfied?</p>



<a name="216606732"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20GAT%3F/near/216606732" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20GAT.3F.html#216606732">(Nov 13 2020 at 13:02)</a>:</h4>
<p><code>&lt;T as Trait&gt;::Item&lt;'a&gt;</code> is pretty much identical to <code>&lt;T as Trait&lt;'a&gt;&gt;::Item</code> so i don't completely understand what you are concerned about.</p>



<a name="216607093"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20GAT%3F/near/216607093" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Avi Dessauer <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20GAT.3F.html#216607093">(Nov 13 2020 at 13:05)</a>:</h4>
<p>I'm concerned that this isn't likly a fix.<br>
<a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=fab410da6162fe39b6d36a4bf0bc3c15">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=fab410da6162fe39b6d36a4bf0bc3c15</a></p>



<a name="216607256"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20GAT%3F/near/216607256" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20GAT.3F.html#216607256">(Nov 13 2020 at 13:07)</a>:</h4>
<p>probably, but that constraint seems meaningless to me</p>



<a name="216607308"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20GAT%3F/near/216607308" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20GAT.3F.html#216607308">(Nov 13 2020 at 13:07)</a>:</h4>
<p>because at this point you can just use <code>T::Item&lt;'a&gt;</code> for both <code>a</code> and <code>b</code></p>



<a name="216607318"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20GAT%3F/near/216607318" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20GAT.3F.html#216607318">(Nov 13 2020 at 13:07)</a>:</h4>
<p>or add a new generic param <code>U</code></p>



<a name="216607358"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20GAT%3F/near/216607358" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20GAT.3F.html#216607358">(Nov 13 2020 at 13:08)</a>:</h4>
<p>and use that instead of <code>T::Item&lt;'_&gt;</code></p>



<a name="216607676"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20GAT%3F/near/216607676" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Avi Dessauer <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20GAT.3F.html#216607676">(Nov 13 2020 at 13:11)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/144729-wg-traits/topic/Variance.20.26.20GAT.3F/near/216607256">said</a>:</p>
<blockquote>
<p>probably, but that constraint seems meaningless to me</p>
</blockquote>
<p>Yeah, that's my concern.</p>



<a name="216607899"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20GAT%3F/near/216607899" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20GAT.3F.html#216607899">(Nov 13 2020 at 13:13)</a>:</h4>
<p>meaningless in the sense that it shouldn't be necessary, not in the sense that it won't help</p>



<a name="216608184"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20GAT%3F/near/216608184" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Avi Dessauer <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20GAT.3F.html#216608184">(Nov 13 2020 at 13:16)</a>:</h4>
<p>What would make it compile then?<br>
A <code>T::Item&lt;'a&gt;: Covariant</code> constraint?</p>



<a name="216608227"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20GAT%3F/near/216608227" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20GAT.3F.html#216608227">(Nov 13 2020 at 13:16)</a>:</h4>
<p>it feels to me like you are somehow focusing on something really specific which seems limiting in isolation but isn't actually relevant when viewed from above. It might help to add some more examples of what you are concerned with and I can try to adapt them to how I would implement them</p>



<a name="216608295"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20GAT%3F/near/216608295" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20GAT.3F.html#216608295">(Nov 13 2020 at 13:17)</a>:</h4>
<p><span class="user-mention silent" data-user-id="209924">Avi Dessauer</span> <a href="#narrow/stream/144729-wg-traits/topic/Variance.20.26.20GAT.3F/near/216608184">said</a>:</p>
<blockquote>
<p>What would make it compile then?<br>
A <code>T::Item&lt;'a&gt;: Covariant</code> constraint?</p>
</blockquote>
<p>not using <code>T::Item&lt;'a&gt;</code> and <code>T::Item&lt;'b&gt;</code> in the first place <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<a name="216609746"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20GAT%3F/near/216609746" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Avi Dessauer <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20GAT.3F.html#216609746">(Nov 13 2020 at 13:29)</a>:</h4>
<p>I don't think we can call GATs to be created within the same scope "specific".<br>
This was even pointed out on the <a href="https://github.com/rust-lang/rfcs/pull/1598#issuecomment-381638842">RFC PR</a></p>



<a name="216612132"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Variance%20%26%20GAT%3F/near/216612132" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Variance.20.26.20GAT.3F.html#216612132">(Nov 13 2020 at 13:46)</a>:</h4>
<p>I personally don't believe this to be fruitful without some examples which you consider to be not be possible due to this restriction.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>